package cn.fl.project.service.impl;

import java.util.List;

import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.project.api.IPrjPaySchMYqApiService;
import cn.fl.project.condition.PrjPaySchMYqQC;
import cn.fl.project.dto.PrjPaySchMYqDTO;
import cn.fl.project.dto.PrjPrdDtlDTO;
import cn.fl.project.service.IPrjPaySchMYqService;
import cn.fl.project.transform.PrjPaySchMYqVOTransform;
import cn.fl.project.transform.PrjPaySchMYqWebVOTransform;
import cn.fl.project.transform.PrjPrdDtlVOTransform;
import cn.fl.project.vo.PrjPaySchMYqVO;
import cn.fl.project.vo.PrjPaySchMYqWebVO;
import cn.fl.project.vo.PrjPrdDtlVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cmm.mid.core.framework.page.Pager;


/**
 * @Description: 疫情项目与支付表关系表信息 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class PrjPaySchMYqServiceImpl implements IPrjPaySchMYqService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(PrjPaySchMYqServiceImpl.class);
	
	/**
	 * 自定义 API 自行注入需要的API服务
	 */
	@Autowired
	private IPrjPaySchMYqApiService prjPaySchMYqApiService;

	@Override
	public PrjPaySchMYqVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException( "获取对象主键不能为空!");
		}
		//TODO 业务逻辑
		PrjPaySchMYqDTO dto = this.prjPaySchMYqApiService.selectById(id);
		return PrjPaySchMYqVOTransform.toVO(dto);
	}

	@Override
	public Long add(PrjPaySchMYqVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不存在!");
			throw new BaseException("新增对象不存在!");
		};
		return this.prjPaySchMYqApiService.insert(PrjPaySchMYqVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除对象主键不能为空!");
			throw new BaseException("删除对象主键不能为空!");
		};
		return this.prjPaySchMYqApiService.removeById(id);
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
		if(CollectionUtils.isEmpty(ids)){
			BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException("删除对象主键不能为空!");
		};
		return this.prjPaySchMYqApiService.removeByIds(ids);
    }
	/**
     * 按项目id删除
     * @param prjIds
     * @return
     */
    public boolean removeByPrjIds(List<Long> prjIds)throws BaseException{
		if(CollectionUtils.isEmpty(prjIds)){
			BaseLogUtils.info(logger, "removeByIds", "删除prjIds参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			throw new BaseException("删除对象主键不能为空!");
		};
		return this.prjPaySchMYqApiService.removeByPrjIds(prjIds);
    }

	@Override
	public boolean modify(PrjPaySchMYqVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象不能为空!");
			throw new BaseException("修改对象不能为空!");
		};
		//TODO 业务逻辑
		return this.prjPaySchMYqApiService.modify(PrjPaySchMYqVOTransform.toDTO(entity));
	}

	/**
	 * 查询列表
	 * @param qc
	 * @return
	 */
	@Override
	public List<PrjPaySchMYqVO> searchList(PrjPaySchMYqQC qc)throws BaseException{
		if(null == qc){
			BaseLogUtils.info(logger, "modify", "修改对象不能为空!");
			throw new BaseException("修改对象不能为空!");
		};
		//TODO 业务逻辑
		return PrjPaySchMYqVOTransform.toVOList(this.prjPaySchMYqApiService.searchList(qc));

	}

	@Override
	public List<PrjPaySchMYqWebVO> getPrjPrdPaySchMList(PrjPaySchMYqQC qc) throws BaseException {
		if(null == qc){
			BaseLogUtils.info(logger, "getPrjPrdPaySchMList", "查询参数不能为空!");
			throw new BaseException("查询参数不能为空!");
		};
		return PrjPaySchMYqWebVOTransform.toVOList(this.prjPaySchMYqApiService.getPrjPrdPaySchMList(qc));
	}
	@Override
	public List<PrjPaySchMYqWebVO> getPrjPrdPaySchMForZfList(PrjPaySchMYqQC qc) throws BaseException {
		if(null == qc){
			BaseLogUtils.info(logger, "getPrjPrdPaySchMForZfList", "查询参数不能为空!");
			throw new BaseException("查询参数不能为空!");
		};
		return PrjPaySchMYqWebVOTransform.toVOList(this.prjPaySchMYqApiService.getPrjPrdPaySchMForZfList(qc));
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page){
			page = new Pager();
		}
		page = this.prjPaySchMYqApiService.searchListPage(page);
		List<PrjPrdDtlVO> list = PrjPrdDtlVOTransform.toVOList((List<PrjPrdDtlDTO>)page.getResultList());
		page.setResultList(list);
		return page;
	}
}
